﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Model;

namespace PMS.Web
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.TextBoxEmployeeNo.Focus();
            this.TextBoxEmployeeNo.Attributes.Add("onkeydown", "clearDefaultTextByKeydown()");
        }


        /// <summary>
        /// 登录按钮事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ButtonLogin_Click(object sender, ImageClickEventArgs e)
        {
            PMS_UserBLL bll = new PMS_UserBLL();
            string account = this.TextBoxEmployeeNo.Text.Trim();
            string Password = this.TextBoxPassword.Text;
            //DB中是否存在
            //LoginByEmail(email, Password);
            //LoginByAccount(account, Password);
            PMS_User result = bll.Login(account, Password);

            if (result == null)  //密码错误
            {
                ClientScript.RegisterStartupScript(this.GetType(), "msg", "alert('用户名或密码错误!');", true);
                return;
            }
            else
            {
                Session["UserInfo"] = result;
                Response.Redirect("ProjectMaintain.aspx");
            }
        }
    }
}